<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link rel='stylesheet' href='pluginsCss.css'></link>
    <link rel='stylesheet' href='plugins.css'></link>
    <link rel='stylesheet' href='luckysheet.css'></link>
    <link rel='stylesheet' href='iconfont.css'></link>
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="plugin.js"></script>
    <script type="text/javascript" src="luckysheet.umd.js"></script>
    <script type="text/javascript" src="my.js"></script>
    <script type="text/javascript">
    $(function () {
        var user = $.loadUser("user");
        var file = $.loadFile("file");

        var autoSave;
        //配置项
        var options = {
            lang: 'zh',
            title: file + " @" + user,
            container: 'luckysheet',
            allowUpdate: true,
            loadUrl:"http://"+ location.host +"/get/" + file,
            hook:{
                updated:function(e){
                    //监听更新,并在1s后自动保存
                    if(autoSave) clearTimeout(autoSave)
                    $(luckysheet_info_detail_save).text("已修改")
                    autoSave = setTimeout(function(){
                        var excel = luckysheet.getAllSheets();
                        //去除临时数据,减小体积
                        for(var i in excel) excel[i].data = undefined
                        $.post(
                            "http://" + location.host + "/set/" + file,
                            {jsonExcel:JSON.stringify(excel)},
                            function(){
                                $(luckysheet_info_detail_save).text("已保存")
                            })
                    },2 * 1000)
                    return true;
                }
            },
            updateUrl: "ws://" + location.hostname +":11551/" + user
        }

        //console.log(JSON.stringify(options))
        luckysheet.create(options)
    })

    </script>
</head>
<body>
<div id="luckysheet" style="margin:0px;padding:0px;position:absolute;width:100%;height:100%;left: 0px;top: 0px;"></div>
</body>
</html>